package com.windhc.taotao.config;

import com.alibaba.fastjson2.JSONWriter;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.serialization.fastjson2.Fastjson2ActionExecutor;
import org.noear.solon.serialization.fastjson2.Fastjson2RenderFactory;

/**
 * @author windhc
 */
@Configuration
public class AppConfig {

    /**
     * json序列化配置
     *
     * @param factory  用于处理 json 渲染输出
     * @param executor 用于执行 json 内容的请求
     */
    @Bean
    public void jsonInit(@Inject Fastjson2RenderFactory factory, @Inject Fastjson2ActionExecutor executor) {

//        factory.addEncoder(LocalDate.class, new LocalDateSerializer());

        // 需要手动把BaseEnum的每个子类注册到Encoder中
//        factory.addEncoder(WithdrawStatus.class, new CustomEnumSerializer());

        // 移除 - 在大范围超过JavaScript支持的整数，输出为字符串格式
        factory.removeFeatures(JSONWriter.Feature.BrowserCompatible);
    }
}
